﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Opera;
using OpenQA.Selenium.Safari;

using System.Collections.Concurrent;
using AutoTestingFramework.Core.Configurations;
using System.IO;

using AutoTestingFramework.Core.WebDrivers;


namespace AutoTestingFramework.Core.WebDrivers
{
    public class WebBroswerFactory : IWebBroswerFactory
    {
        public Func<IWebDriver> GenerateBrowserSpecificDriver(WebBroswerType webBroswerType,IWebDriverSettings settings)
        {
            string driverPath = settings.DriverServerDirectory;

            switch (webBroswerType)
            {
                case WebBroswerType.Chrome:
                    return new Func<IWebDriver>(() => new ChromeWebDriverWrapper(driverPath, settings.CommandTimeout));
                case WebBroswerType.Edge:
                    break;
                case WebBroswerType.Firefox:
                    return new Func<IWebDriver>(() => new FirefoxWebDriverWrapper(settings.CommandTimeout));
                case WebBroswerType.IE:
                    return new Func<IWebDriver>(() => new IEWebDriverWrapper(driverPath, settings.CommandTimeout));
                case WebBroswerType.IE64:
                    break;
                case WebBroswerType.Opera:
                    break;
                case WebBroswerType.Safari:
                    break;
                case WebBroswerType.Remote:
                    return new Func<IWebDriver>(() => new RemoteWebDriverWrapper(settings.HubURL, settings.BrowserCapability));
                default:
                    break;
            }

            throw new NotImplementedException("Selected browser " + webBroswerType.ToString() + " is not supported yet.");
        }
    }
}
